# -*- coding:latin-1 -*-

#####################################
# Date: 05/04/10                    #
# Auteur: Rigaut Maximilien         #
# Nom: Gomoku  [Packer]             #
# Version: 1.0                      #
# Copyright 2010: Rigaut Maximilien #
#####################################
#    This file is part of Gomoku.
#
#    Gomoku is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Gomoku is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Gomoku.  If not, see <http://www.gnu.org/licenses/>.
#################################

from tarfile import open
import os

nom="Gomoku"
v=raw_input("Version du programme: ")
mode=raw_input("Mode [(A)ll/(E)xport] ")

if mode=='A':
    nom=nom+'_All '+v+'.tar.gz'
    tFile= open(nom,'w:gz')
    fichiers=os.listdir('.')
    fichiers.pop(fichiers.index('Archives'))
    for fichier in fichiers:
        tFile.add(fichier,fichier,True)
    tFile.close()
elif mode == 'E':
    nom=nom+v+'.tar.gz'
    tFile= open(nom,'w:gz')
    fichiers=['Gomoku.py','COPIE.txt','COPYING.txt']
    fichiers+=['Modules/Graphix.py','Modules/loadModule.py','Modules/IAgomoko.py','Modules/6772656564696e6773.bob']
    fichiers+=['Preferences/preference.dat','Preferences/Presets.txt']
    fichiersR=['Ressources/En']
    fichiersR+=['Ressources/Fr']
    for fichier in fichiers:
        tFile.add(fichier)
    for fichier in fichiersR:
        tFile.add(fichier,fichier,True)
    tFile.close()
else:
    print "Mode invalide !"
os.rename(nom,'./Archives/'+nom)